Skip to content

fix: Fix deadlock issues by adding ConfigureAwait(false) - #306

Merged
thomhurst merged 2 commits into
mainfrom
fix/deadlock-configureawait-issues
Aug 8, 2025
Merged

fix: Fix deadlock issues by adding ConfigureAwait(false)#306
thomhurst merged 2 commits into
mainfrom
fix/deadlock-configureawait-issues

Conversation

@thomhurst

Copy link
Copy Markdown
Owner

This commit addresses critical deadlock issues that were causing libraries to hang:

  1. Fixed synchronous Dispose() methods that were blocking on async disposal

    • Added ConfigureAwait(false) to prevent synchronization context capture
    • Added exception handling to suppress disposal exceptions per IDisposable pattern
  2. Added ConfigureAwait(false) to all await statements in library code

    • Updated 25 files with 200+ await statements
    • Covers all async patterns: Task.WhenAll, Task.Run, async foreach, etc.
    • Ensures no synchronization context capture in library code

This prevents deadlocks when the library is used in UI or ASP.NET contexts where the synchronization context can cause blocking.

All 498 tests pass confirming no functionality was broken.

…ibrary

This commit addresses critical deadlock issues that were causing libraries to hang:

1. Fixed synchronous Dispose() methods that were blocking on async disposal
   - Added ConfigureAwait(false) to prevent synchronization context capture
   - Added exception handling to suppress disposal exceptions per IDisposable pattern

2. Added ConfigureAwait(false) to all await statements in library code
   - Updated 25 files with 200+ await statements
   - Covers all async patterns: Task.WhenAll, Task.Run, async foreach, etc.
   - Ensures no synchronization context capture in library code

This prevents deadlocks when the library is used in UI or ASP.NET contexts
where the synchronization context can cause blocking.

All 498 tests pass confirming no functionality was broken.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Found and fixed additional methods that were returning Task.WhenAll directly
without awaiting with ConfigureAwait(false). This completes the comprehensive
ConfigureAwait(false) implementation across the entire library.

Fixed files:
- BatchAsyncProcessor.cs & BatchAsyncProcessor_1.cs
- ParallelAsyncProcessor.cs & ParallelAsyncProcessor_1.cs
- UnboundedParallelAsyncProcessor.cs & UnboundedParallelAsyncProcessor_1.cs
- ResultBatchAsyncProcessor_1.cs & ResultBatchAsyncProcessor_2.cs
- ResultParallelAsyncProcessor_1.cs & ResultParallelAsyncProcessor_2.cs
- ResultUnboundedParallelAsyncProcessor_1.cs & ResultUnboundedParallelAsyncProcessor_2.cs

All methods now properly use async/await with ConfigureAwait(false) pattern.
All 498 tests pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thomhurst
thomhurst merged commit bfe0bb2 into main Aug 8, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant